# Maintainer: Antoine Martin <antoine@xpra.org>
# Contributor: ZaZam <zazaamm æt gmail døt com>
# Contributor: Yegorius <yegorius@domic.us>

pkgname="${MINGW_PACKAGE_PREFIX}-python2-zeroconf"
_srcname=python-zeroconf
pkgver=0.19.1
pkgrel=1
pkgdesc="A pure python implementation of multicast DNS service discovery"
arch=('any')
url="https://github.com/jstasiak/python-zeroconf"
license=('LGPL')
depends=("${MINGW_PACKAGE_PREFIX}-python2"
         "${MINGW_PACKAGE_PREFIX}-python2-netifaces"
	 "${MINGW_PACKAGE_PREFIX}-python2-six"
	 "${MINGW_PACKAGE_PREFIX}-python2-enum34")
makedepends=("${MINGW_PACKAGE_PREFIX}-python2-setuptools")
#checks are skipped at the moment:
#checkdepends=("${MINGW_PACKAGE_PREFIX}-python2-mock")
source=("${_srcname}-${pkgver}.tar.gz"::"https://github.com/jstasiak/${_srcname}/archive/${pkgver}.tar.gz")
sha256sums=('ca8952a3eb04818dcb566e1344f2f15b5dd6d487770384651cdfae777d5eb848')

prepare() {
  cd "${srcdir}/${_srcname}-${pkgver}"

  # No need for enum-compat if depend on enum34
  sed -i "s/'enum-compat',//" setup.py
}

build() {
  cd "${srcdir}/${_srcname}-${pkgver}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
    ${MINGW_PREFIX}/bin/python2 setup.py build
}

package() {
  cd "${srcdir}/${_srcname}-${pkgver}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
    ${MINGW_PREFIX}/bin/python2 setup.py install --prefix=${MINGW_PREFIX} \
	 --root="$pkgdir" --optimize=1
  install -Dm644 COPYING "${pkgdir}${MINGW_PREFIX}/share/licenses/python2-zeroconf/COPYING"
  install -Dm644 README.rst "${pkgdir}${MINGW_PREFIX}/share/doc/python2-zeroconf/README"
}

check() {
  echo "test skipped because python-mock currently fails to import"
  echo "see 'python2 -c \"from mock import patch\"'"
  #cd "${srcdir}/${_srcname}-${pkgver}"
  #py.test .
}
